package mx.com.erl.billar.dao.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.ParameterizedBeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import mx.com.erl.billar.dao.InventarioDao;
import mx.com.erl.billar.dto.Inventario;


@Repository
public class InventarioDaoImpl extends JdbcDaoSupport implements InventarioDao{
	
	@Autowired
	public InventarioDaoImpl(DataSource dataSource){
		setDataSource(dataSource);
	}

	

	@Override
	public int selectExistenciaByProducto(String producto) {
		// TODO Auto-generated method stub
		PreparedStatement ps = null;
		int existencia=0;
		ResultSet rs;
		//int existenciacerveza=0;
		
		// consultar existencia del producto
		String sql="select existencia from inventario where produto=?";
		return 0;
		
	}

	@Override
	public float selectCostoByProducto(String producto) {
		// TODO Auto-generated method stub
		return 0;
	}



	@Override
	public List<Inventario> selectAllInventario() {
		// TODO Auto-generated method stub
		return getJdbcTemplate().query("select produto,existencia from inventario",
				ParameterizedBeanPropertyRowMapper.newInstance(Inventario.class));
	}

}
